<layout name="page" />
<block name="content">
	<input type="hidden" name="popup_val" id="popup_val">
	<input type="hidden" name="popup_name" id="popup_name">
	<div class="form-group hidden" id="img_upload_container">
		<div id="img_upload">
			上传
		</div>
	</div>
	{:widget('page_header/simple',array('name'=>'新建：'.$flow_type['name']))}
	<div class="operate-panel">
		<a onclick="go_return_url();" class="btn">返回</a>
		<eq name="flow_type.is_lock" value="0">
			<a id="btn_popup_confirm"  class="btn">选择审批流程</a>
		</eq><div class="split"></div>
		<a id="btn_darft" class="btn">存草稿</a>
		<a id='btn_save' class="btn">提交</a>
	</div>
	<div class="frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data" >
			<input type="hidden" id="ajax" name="ajax" value="1">
			<input type="hidden" id="type" name="type" value="{$flow_type.id}">
			<input type="hidden" id="opmode" name="opmode" value="add">
			<input type="hidden" id="confirm" name="confirm" value="">
			<input type="hidden" id="confirm_name" name="confirm_name" value="">
			<input type="hidden" id="consult" name="consult" value="">
			<input type="hidden" id="consult_name" name="consult_name" value="">
			<input type="hidden" id="refer" name="refer" value="">
			<input type="hidden" id="refer_name" name="refer_name" value="">
			<input type="hidden" id="step" name="step" value="">

			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="name">标题*：</label>
						
							<input class="input" type="text" id="name" name="name" check="required" info="请输入标题">
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" >文件编号：</label>
						
							<p class="input-static">
								{$flow_type.doc_no_format}
							</p>
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" >审批：</label>
						<div class="input-block address_list_box">
							<p id="confirm_wrap" class="input-static address_list">
								{$flow_type.confirm_name}
							</p>
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" >协商：</label>
						<div class="input-block address_list_box">
							<p id="consult_wrap" class=" input-static address_list">
								{$flow_type.consult_name}
							</p>
						</div>
					</div>
				</div>
			</div>

			<div class="layui-form-item hidden">
				<label class="input-label" >抄送：</label>
				
					<p id="refer_wrap" class="input-static address_list">
						{$flow_type.refer_name}
					</p>
				</div>
			</div>
			<div class="frame">
				<volist name="field_list" id="udf_vo">
					{:widget('UserDefineField/edit',array($udf_vo))}
				</foreach>
			</div>
			<eq name="flow_type.is_show" value="1">
				
					<textarea class="editor" id="content" name="content" style="width:100%;height:300px;">{$flow_type.content}</textarea>
				</div>
			</eq>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" >附件：</label>
						
							{:widget('file_upload/add')}
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<php>
		if($flow_type['is_lock']==0){
	</php>
	<script>
		layui.use(['global'], function() {
			var $ = layui.jquery;
			$('.address_list').on('mouseenter', 'span', function() {
				$(this).find('i').remove();
				$(this).append('<i class="fa fa-times"></i>');
			});
			$('.address_list').on('mouseleave', 'span', function() {
				$i = $(this).find('i');
				$i.removeClass('fa-times');
				$i.addClass('fa-arrow-right');
				$(".address_list span:last i").attr('class', 'fa');
			});

			$('.address_list').on('click', 'i', function() {
				$(this).parents('span').remove();
				$(".address_list span:last i").attr('class', 'fa');
			});
		});
	</script>
	<php>
		}
	</php>
	<script type="text/javascript">
		layui.use(['global', 'udf_field', 'uploader', 'editor'], function() {
			var $ = layui.jquery;
			set_return_url();

			$("#btn_save").on('click', function() {
				$("#confirm").val("");
				$("#confirm_wrap  span").each(function() {
					$("#confirm").val($("#confirm").val() + $(this).attr("data") + '|');
				});

				$("#confirm_name").val($("#confirm_wrap").html());

				$("#consult").val("");
				$("#consult_wrap  span").each(function() {
					$("#consult").val($("#consult").val() + $(this).attr("data") + '|');
				});
				$("#consult_name").val($("#consult_wrap").html());

				if ($("#confirm").val().length < 2) {
					layer.msg('请选择审批流程');
					return false;
				}

				$("#step").val(20);
				send_form("form_data", "{:url('save')}", "{:url('index')}", function(ret) {
					if (ret.status) {
						layer.msg(ret.info);
						location.href = "{:url('index')}";
					} else {
						layer.msg(ret.info);
						return false;
					}
				});
			});

			$("#btn_darft").on('click', function() {
				$("#confirm").val("");
				$("#confirm_wrap  span").each(function() {
					$("#confirm").val($("#confirm").val() + $(this).attr("data") + '|');
				});

				$("#confirm_name").val($("#confirm_wrap").html());

				$("#consult").val("");
				$("#consult_wrap  span").each(function() {
					$("#consult").val($("#consult").val() + $(this).attr("data") + '|');
				});
				$("#consult_name").val($("#consult_wrap").html());

				if ($("#confirm").val().length < 2) {
					ui_error('请选择审批流程');
					return false;
				}

				$("#step").val(10);
				send_form("form_data", "{:url('save')}", "{:url('index')}", function(ret) {
					if (ret.status) {
						layer.msg(ret.info);
						location.href = "{:url('index')}";
					} else {
						layer.msg(ret.info);
						return false;
					}
				});
			});

			$('#btn_popup_confirm').on('click', function() {
				winopen("{:url('popup/confirm')}", 560, 470);
			});
		});
	</script>
</block>